﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using PCManagerReloaded.ViewModel;

namespace PCManagerReloaded
{
    public partial class WindowsPage : PhoneApplicationPage
    {
        public WindowsPage()
        {
            InitializeComponent();
        }

        private void ApplicationBarIconButton_Click(object sender, EventArgs e)
        {
            var viewModel = this.DataContext as WindowsViewModel;
            if (viewModel != null) viewModel.Refresh();
        }

        private void ToggleSwitch_Checked(object sender, RoutedEventArgs e)
        {
            var toggleSwitch = sender as ToggleSwitch;

            var viewModel = this.DataContext as WindowsViewModel;
            if (viewModel != null && toggleSwitch != null && toggleSwitch.IsChecked.HasValue)
            {
                    viewModel.RequestShutdown();
            }
        }

        private void ToggleSwitch_Unchecked(object sender, RoutedEventArgs e)
        {
            var toggleSwitch = sender as ToggleSwitch;

            var viewModel = this.DataContext as WindowsViewModel;
            if (viewModel != null && toggleSwitch != null && toggleSwitch.IsChecked.HasValue)
            {
                    viewModel.CancelShutdown();
            }
        }
    }
}